#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    m_res=connect(this,SIGNAL(Comeon(QString&)),this,SLOT(ComeonGuys(QString&)));
    connect(this,SIGNAL(Comeon(QString&)),this,SLOT(ComeonChina(QString&)));
    connect(this,SIGNAL(Comeon(QString&)),this,SLOT(ComeonHuaxia()));


    connect(this,SIGNAL(Comeon2()),this,SLOT(ComeonHuaxia()));
    connect(this,SIGNAL(Comeon3()),this,SLOT(ComeonHuaxia()));
    connect(this,SIGNAL(Comeon4()),this,SLOT(ComeonHuaxia()));

    connect(this,SIGNAL(Comeon(QString&)),this,SIGNAL(Comeon2()));
    connect(this,SIGNAL(Comeon2),this,SLOT(ComePeople()));

   // connect(this,&MainWindow::Comeon,this,&MainWindow::ComeonGuys);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_whbtn_clicked()
{
    QString str ="武汉加油";
    emit Comeon(str);
}

void MainWindow::on_zgbtn_clicked()
{
    QString str ="中国加油";
    emit Comeon(str);
}

void MainWindow::on_sjbtn_clicked()
{
    QString str ="世界加油";
    emit Comeon(str);
    emit Comeon2();
    emit Comeon3();
    emit Comeon4();
}

void MainWindow::ComeonGuys(QString &str)
{
    qDebug()<<str;
}

void MainWindow::ComeonChina(QString &str)
{
    qDebug()<<"大中国加油！";
}

void MainWindow::ComeonHuaxia()
{
    qDebug()<<"华夏子孙加油！";
}

void MainWindow::ComePeople()
{
     qDebug()<<"人类加油！";
}


void MainWindow::on_pushButton_clicked()
{
    qDebug()<<"断开Comeon信号与ComeonGuys槽的连接";
   // disconnect(this,SIGNAL(Comeon(QString&)),this,SLOT(ComeonGuys(QString&)));
   disconnect(m_res);
}

void MainWindow::on_pushButton_2_clicked()
{
    qDebug()<<"断开Comeon信号与ComeonGuys槽的连接";
    disconnect(this,SIGNAL(Comeon(QString&)),0,0);
}



void MainWindow::on_pushButton_3_clicked()
{
    qDebug()<<"断开this发射所有信号与this对象所有槽的连接";
    disconnect(this,0,this,0);
    //disconnect(this,0,0,0);    //断开this所有相关对象的槽的响应
}
